﻿using System;
using System.Reflection;

namespace Interactive.Utility.Reflect {
    /// <summary>
    /// 反射帮助类
    /// </summary>
    public static class Helper {
        /// <summary>
        /// 得到要反射的对象
        /// </summary>
        /// <param name="assemblyName">程序集名</param>
        /// <param name="className">类名</param>
        /// <returns>返回要反射的对象</returns>
        public static object GetObject(string assemblyName, string className){
            Assembly assembly = string.IsNullOrEmpty(assemblyName)
                                    ? Assembly.GetEntryAssembly()
                                    : Assembly.Load(assemblyName);
            Type type = assembly.GetType(className, true, true);
            return Activator.CreateInstance(type, false);
        }
    }
}